// pages/accountSecurely/accountSecurely.js
var common = require("../../utils/Conmon.js");
var appData = getApp().globalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    AccountName:null,
    Phone:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     var that=this;
     common.pageInit( function () {
     });
     wx.showLoading({ title: '加载中...', mask: true });
     that.wxSubRequest('GET', 'http://zp4.bapi.cn/member/api/MemberCenter/Account', { UserId: wx.getStorageSync('UserInfo').UserID, CustId: appData.custID },
       function (data) {
         if (data.code == 1200) {
           wx.hideLoading()
           that.setData({
             AccountName: data.content.UserinfoModel.userinfoApiDto.AccountName,
             Phone: data.content.UserinfoModel.userinfoApiDto.Phone
           })
         }
       },
       function (obj) {
         wx.hideLoading()
         console.log(obj)
       })
  },

 /**
  * 绑定更换手机号点击事件
  */
  bindPhoneClickTap:function(event){
     var that=this;
     var phone = event.currentTarget.id;
     wx.redirectTo({
       url: '/pages/currentlyPhone/currentlyPhone?phone=' + phone,
     })
  },

  /**
   * 微信提交请求获取数据或保存数据
   * 
   */
  wxSubRequest: function (method, url, param, callBack, CallBackError) {
    wx.request({
      url: url,
      method: method,
      data: param,
      header: {
        "content-type": "application/json",
        'X_ManuName': appData.manuName

      },
      success: function (res) {
        if (res.statusCode == 200 && res.data.code == 1200) {
          var data = res.data;
          callBack(data)
          console.log(res.data)
        }
      },
      fail: function (res) {
        CallBackError(res.data)
        console.log(res.data)
      },
      complete: function (res) {
        console.log(res.msg)
      }
    })
  },

  /***********************************************/

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})